﻿using MoetutuServer.Helper;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MoetutuServer.PostHelper
{
    class LoadUserInfo
    {

        public static UserData GetUserData(String FileName) {
            UserData userData = new UserData();


            try
            {
                UserInofRoot userInofRoot = JsonConvert.DeserializeObject<UserInofRoot>(File.ReadAllText(FileName));
                userData.UserName1 = userInofRoot.username;
                userData.UserPass1 = userInofRoot.userpass;
                userData.WebHost = userInofRoot.WebHost;
            }
            catch (Exception ex) {
                PrintLog.Log(ex);
            }
            return userData;


        }

        public struct UserData {
            String UserName;
            string UserPass;
            string webHost;
         
            public string UserName1 { get => UserName; set => UserName = value; }
            public string UserPass1 { get => UserPass; set => UserPass = value; }
            public string WebHost { get => webHost; set => webHost = value; }

            public override bool Equals(object obj)
            {
                return base.Equals(obj);
            }

            public override int GetHashCode()
            {
                return base.GetHashCode();
            }

            public override string ToString()
            {
                return base.ToString();
            }
        }
     
    }

    public class UserInofRoot
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string username { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string userpass { get; set; }

        /// <summary>
        /// post向的网站
        /// </summary>
        public string WebHost { get; set; }
    }

}
